package org.iteam.xlz.core.service.ad;

import java.sql.SQLException;

import org.iteam.core.utils.SqlBuilder;
import org.iteam.db.BaseService;
import org.iteam.xlz.core.entity.ad.AdIdVo;

public class AdIdService extends BaseService<AdIdVo>{
	static AdIdService instance;
	
	private AdIdService(){
	}
	
	public static AdIdService getInstance(){
		if(null==instance){
			instance=new AdIdService();
		}
		return instance;
	}
	
	public boolean create(AdIdVo model){
		SqlBuilder builder=SqlBuilder.createInsert("adid");
		builder.addField("aid",model.getAid());
		builder.addField("sid",model.getSid());
		try {
			return super.update(builder.getSql(),builder.getParams());
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
	}
	
	public AdIdVo findById(String id){
		try {
			return super.show("select * from adid where 1=1 and id=?",id);
		} catch (SQLException e) {
			e.printStackTrace();
			return new AdIdVo();
		}
	}
	
	public boolean delete(String sid){
		try {
			return super.updates("delete from adinfo where sid=?",sid)>0;
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
	}
}
